package writer_;

import org.junit.Test;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class BufferedWriter_ {
    public static void main(String[] args) {

    }
    @Test
    public void bufferedWriter_(){
        //用BufferedWriter写文件
        BufferedWriter bufferedWriter = null;
        try {
            bufferedWriter = new BufferedWriter(new FileWriter("D:\\xuexi\\str2.txt"));
            bufferedWriter.write("早晨，一个少女来湖边叹气，\n" +
                    "十六岁的影子比红宝石美丽。\n" +
                    "\n" +
                    "青海省城有一个郡王，可怕的\n" +
                    "欲念，象他满腮浓黑的胡须，");
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bufferedWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
